<%@ page import="myschool.entity.Subject" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="myschool.mybatisUtil.MybatisUtil" %>
<%@ page import="myschool.dao.SubjectDao" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/6/6
  Time: 17:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    String subId = request.getParameter("id");
    String newSubjectName=request.getParameter("newSubjectName");
    String classHour = request.getParameter("classHour");
    String gradeID = request.getParameter("gradeID");

        Subject subject = new Subject();
        subject.setId(Integer.parseInt(subId));
        if (newSubjectName!=null){
            subject.setSubjectname(newSubjectName);
        }
        if (classHour!=null){
            subject.setClasshour(Integer.parseInt(classHour));
        }
        subject.setGradeid((long) Integer.parseInt(gradeID));

    SqlSession s= MybatisUtil.get();
    SubjectDao mapper = s.getMapper(SubjectDao.class);
    mapper.update(subject);
    MybatisUtil.close(s);
    response.sendRedirect("Subject.jsp");
%>
</body>
</html>
